package test;

import java.util.Scanner;

public class Demo2 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[][] num = new int[n][m];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    num[i][j] = scanner.nextInt();
                }
            }
            int max = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    int temi = i;
                    int temj = j;
                    int sum = 0;
                    for (int k = 0; k <= temi; k++) {

                        for (int l = 0; l <= temj; l++) {
                            sum = sum + num[k][l];
                        }
                    }
                    max = Math.max(max, sum);
                }
            }

            for (int i = n - 1; i >= 0; i--) {
                for (int j = m - 1; j >= 0; j--) {
                    int temi = i;
                    int temj = j;
                    int sum = 0;
                    for (int k = temi; k <= n - 1; k++) {

                        for (int l = temj; l <= m - 1; l++) {
                            sum = sum + num[k][l];
                        }
                    }
                    max = Math.max(max, sum);
                }
            }


            System.out.println(max);
        }

    }
}
